package server;

import java.io.InputStream;
import java.io.OutputStream;

/**
 * '通用框架'
 * 用于规定处理业务逻辑的大逻辑.看后面具体代码要如何调用,这是一个设计的思想以及经验.
 */
public abstract class HttpServlet implements Servlet{
    public abstract void doGet(Request request,Response response) throws InterruptedException;

    public abstract void doPost(Request request,Response response);

    @Override
    public void service(Request request,Response response) {
        String method = request.getMethod();

        if("GET".equals(method)){
            try {
                doGet(request,response);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            doPost(request,response);
        }
    }
}
